﻿Imports System.IO
Imports AjaxControlToolkit
Imports System.Web.Services
Imports System.Web.Script.Services
Imports System.Collections.Generic

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    <WebMethod()> _
<ScriptMethod()> _
Public Shared Function GetImages() As Slide()
        Dim slides As List(Of Slide) = New List(Of Slide)()
        Dim sPath As String = HttpContext.Current.Server.MapPath("~/SlideImages/")
        If sPath.EndsWith("\") Then
            sPath = sPath.Remove(sPath.Length - 1)
        End If
        Dim pathUri As Uri = New Uri(sPath, UriKind.Absolute)
        Dim files As Array = Directory.GetFiles(sPath)
        For Each file As String In files
            Dim filePathUri As New Uri(file, UriKind.Absolute)
            slides.Add(New Slide() With {.Name = Path.GetFileNameWithoutExtension(file), .Description = Path.GetFileNameWithoutExtension(file) + " Description.", .ImagePath = pathUri.MakeRelativeUri(filePathUri).ToString()})
        Next
        Return slides.ToArray()
    End Function

End Class